<?php
class Ddup_Tags_Model_Tag extends Mage_Tag_Model_Tag
{
	/**
     * URL Model instance
     *
     * @var Mage_Core_Model_Url
     */
    protected static $_url;
    
	public function getTaggedProductsUrl()
    {
    	if (Mage::getStoreConfig('tags/settings/rewrites_enabled')) {
	        $rewrite = Mage::getResourceModel('tags/url')->getRewriteByIdPath('tag/' . $this->getTagId(), Mage::app()->getStore()->getId());
	        if ($rewrite and $rewrite->getRequestPath()) {
	        	return $this->getUrlInstance()->getDirectUrl($rewrite->getRequestPath());
	        }
    	}
        return parent::getTaggedProductsUrl();
    }
    
	/**
     * Retrieve URL instance
     *
     * @return Mage_Core_Model_Url
     */
    public function getUrlInstance()
    {
        if (!self::$_url) {
            self::$_url = Mage::getModel('core/url');
        }
        return self::$_url;
    }
}